﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Web;
namespace ConsoleForGetUrlEncode
{
    class Program
    {
        static void Main(string[] args)
        {
            char cn = '何';
            short ascii = (short)cn;

            //String MyURL;
            
            //MyURL = "http://www.contoso.com/articles.aspx?title=" + Server.UrlEncode("ASP.NET Examples");

            //Response.Write("<a href=" + MyURL + "> ASP.NET Examples </a>");


            //string s = "何";
            //string st = string.Empty;
            //byte[] array = System.Text.Encoding.Default.GetBytes(s);
            //for (int i = 0; i < array.Length; i++)
            //{
            //    if (array[i] >= 161 && array[i] <= 247)
            //    {
            //        st = st + System.Text.Encoding.Default.GetString(array,
            //        i, 2);
            //        st = st + string.Format(" 高字节:{0},低字节:{1}" + Environment.NewLine, array[i], array[i + 1]);
            //        i++;
            //    }
            //    else
            //    {
            //        st = st + System.Text.Encoding.Default.GetString(array,
            //        i, 1);
            //        st = st + string.Format(" ASCII:{0}" +
            //        Environment.NewLine, array[i]);
             //   }
            //}
           // Console.WriteLine(st);



            byte[] bytes = Encoding.Unicode.GetBytes("何");
            byte[] bytes2 = Encoding.Default.GetBytes("何");

            Console.WriteLine(char.ConvertToUtf32("何", 0).ToString());
            //Console.WriteLine(ASCIIEncoding.

            //Console.WriteLine(ascii);
            Console.WriteLine(Convert.ToString(ascii,16));
            Console.WriteLine(bytes[0]);
            Console.WriteLine(bytes[1]);
            Console.WriteLine(Convert.ToString(bytes[0], 16));
            Console.WriteLine(Convert.ToString(bytes[1], 16));
            Console.WriteLine(bytes2[0]);
            Console.WriteLine(bytes2[1]);
            Console.WriteLine(Convert.ToString(bytes2[0], 16));
            Console.WriteLine(Convert.ToString(bytes2[1], 16));


            byte[] utf8 = Encoding.UTF8.GetBytes("何");
            string s3 = ""; string s3d = "";
            foreach (byte b in utf8)
            {
                //s3 += Convert.ToString(b, 16) + " ";
                s3 += string.Format("{0:X2}", b) + " ";
                s3d += b + " ";
            }
            Console.WriteLine(s3);
            Console.WriteLine(s3d);



            Console.Read();
        }

        



    }
}
